package com.tjbklx1.pattern.builder.demo2;

import java.util.ArrayList;

public abstract class CarModel {
	private ArrayList<String> sequence = new ArrayList<String>();
	protected abstract void start();
	protected abstract void stop();
	protected abstract void alarm();
	protected abstract void engineBoom();
	
	//用户自己决定 算法运行的顺序
	final public void run(){
		for(int i=0;i<sequence.size();i++){
			if("start".equals(sequence.get(i))){
				this.start();
			}else if("stop".equals(sequence.get(i))){
				this.stop();
			}else if("alarm".equals(sequence.get(i))){
				this.alarm();
			}else if("engineBoom".equals(sequence.get(i))){
				this.engineBoom();
			}else{
				
			}
		}
	}
	final void setSequence(ArrayList<String> sequence){
		this.sequence=sequence;
	}
}
